<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 数组遍历  for in 不推荐使用遍历数组
        let arr = ['pingk', 'red', 'green']
        for (let k in arr) {
            // console.log(k);      //k是下标，str类型
            // console.log(arr[k]);
        }

        // 创建对象
        let obj = {
            uname: '张三',
            uage: '20',
            ugender: '男'
        }

        // 遍历对象
        for (let key in obj) {
            // console.log(key);
            // console.log(obj[key]);  
            console.log(key, obj[key]);     // 输出属性值obj[key]  key==='uname','uage','gender'
            // console.log(obj['uage']);
        }
    </script>
</body>

</html>